﻿using Unity;
using UnityEngine;

public class MoveSystem
{
    public static void Action(Entity entity)
    {
        if (entity.push!=null && entity.push.IsPush())
        {
            Debug.Log("rotaion:"+ entity.push.rotaion+ "index:" + entity.push.index);
            entity.position.pos.x += Util.SIN(entity.push.rotaion) * entity.push.lineSpeed[entity.push.index] / Util.UnitSpace;
            entity.position.pos.z += Util.COS(entity.push.rotaion) * entity.push.lineSpeed[entity.push.index] / Util.UnitSpace;
            entity.position.pos.y = 0;
            entity.push.index++;
            if (!entity.push.IsPush())
            {
                entity.push = null;
            }
            return;
        }

        if (entity.position!=null && entity.movement!=null){
            entity.position.pos.x += Util.SIN(entity.position.rotaion)*entity.movement.lineSpeed/Util.UnitSpace;
            entity.position.pos.z += Util.COS(entity.position.rotaion) *entity.movement.lineSpeed/Util.UnitSpace;
            entity.position.pos.y = 0;
        }
    }
}
